home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 7 / FM Towns Free Software Collection 7.iso / taropyon / hewin / ccisrc / center01.cci < prev    next >
Text File  |  1993-11-30  |  7KB  |  274 lines

  1. /*************************************************************************
  2. *    "center01.cci" : サンプルセンタープログラム(type 1)
  3. *-------------------------------------------------------------------------
  4. *    BIG-Model系ホスト
  5. *************************************************************************/
  6.  
  7. #ifdef    CENTERKEY
  8. #undef    CENTERKEY
  9. #endif
  10. #ifdef    RECKEY
  11. #undef    RECKEY
  12. #endif
  13.  
  14. /*    #define    _CENTER01_LOGSAVE    */    /* ログ整形ツールを起動するか?    */
  15.  
  16. #define    CENTERKEY    "CENTER01"
  17. #define    RECKEY        _center01_recKey
  18.  
  19. char    *_center01_recKey;
  20.  
  21. int        _CENTER01_init()
  22. {
  23.     char    *center;
  24.  
  25.     if ( (center = NTM_centerAlloc( CENTERKEY )) != NULL )
  26.     {
  27.         NtmCenterSetName   ( center, "Sample center (type-01:BIG-Model)");
  28.         NtmCenterSetFuncKey( center, "CENTER01");
  29.         NtmCenterSetRecKey ( center, "CENTER01");
  30.         NtmCenterSetRsPara ( center, -1, -1, -1 );
  31.         NtmCenterSetRsBreak( center, 50 );
  32.         NtmCenterSetCrWait ( center, 100 );
  33.         NtmCenterSetTel    ( center, "XX-XXXX-XXXX" );
  34.         NtmCenterSetModem1 ( center, "ATZ" );
  35.     }
  36.     return (NORMAL);
  37. }
  38.  
  39.  
  40. /*************************************************************************
  41. *    ナビゲーション用初期化
  42. *************************************************************************/
  43.  
  44. int        _CENTER01_naviInit( char *ntm, char *center )
  45. {
  46. #ifndef    _NAV_IGNORE
  47.     NtmSetNaviServiceMode( ntm, 0 );    /* ナビゲーションシステムなし    */
  48. #endif
  49.     return (NORMAL);
  50. }
  51.  
  52. /*************************************************************************
  53. *    パラメータの指定
  54. *************************************************************************/
  55.  
  56. int        _CENTER01_para( char *ntm, char *center )
  57. {
  58.     char    *keyWord;
  59.     char    *id, *pw;
  60.  
  61.     keyWord = NtmCenterGetKeyWord(center);
  62.     if ( NTM_centerConfig( keyWord ) == NORMAL )
  63.     {
  64.         id  = NtmCenterGetID      ( center );
  65.         pw  = NtmCenterGetPassword( center );
  66.         if ( id[0] == 0 || pw[0] == 0 )
  67.             return (ERR);
  68.         return (NORMAL);
  69.     } else
  70.         return (ERR);
  71. }
  72.  
  73.  
  74. /*************************************************************************
  75. *    処理の中断
  76. *************************************************************************/
  77.  
  78. int        _CENTER01_abort( char *ntm, char *center )
  79. {
  80.     AplRecWrite("%s:Abort", RECKEY);
  81.     NTM_offline( ntm, DTR_OFF_TIME);
  82.     return (NORMAL);
  83. }
  84.  
  85. /*************************************************************************
  86. *    [AUTO]メニュー処理
  87. *************************************************************************/
  88.  
  89. int        _CENTER01_autoMenu( char *ntm, char *center, int x, int y)
  90. {
  91.     int        ret;
  92.     char    *obj;
  93.     char    *mnu;
  94.     char    title[128], tmp[128], tmBuf[32];
  95.     long    loginTime;
  96.  
  97.     if ( ntm == NULL || center == NULL )
  98.         return (0);
  99.     loginTime = NtmCenterGetTime(center, NTM_TIME_LOGIN );
  100.     if ( loginTime )
  101.     {    sprintf( tmp, "Login time %s ", GetAsciiTime(tmBuf,loginTime) );
  102.     } else
  103.     {    strcpy( tmp, "Login time XXXX/XX/XX XX:XX:XX");
  104.     }
  105.     obj = MNU_alloc(3);
  106.     MNU_setObj(obj, 0, MNU_MSG,  0 , tmp               , NULL, 1, NULL, NULL );
  107.     MNU_setObj(obj, 1, MNU_NOR, 'O', "OFF 終了"        , NULL, 1, NULL, NULL );
  108.     MNU_setObj(obj, 2, MNU_NOR, 'B', "OFF 強制回線切断", NULL, 2, NULL, NULL );
  109.  
  110.     sprintf( title, "MENU : %s", NtmCenterGetName(center));
  111.     mnu = MNU_open( x, y, MNUATT_EXIT, obj, title );
  112.     ret = MNU_start ( mnu );
  113.     MNU_close(mnu);
  114.     MNU_free(obj);
  115.     switch ( ret )
  116.     {
  117.         case    1:
  118.             return    NTM_callLogout( ntm );
  119.         case    2:
  120.             NTM_wait(3);
  121.             AplRecWrite("%s:Abort disconnect", RECKEY);
  122.             return    NTM_offline(ntm, DTR_OFF_TIME);
  123.     }
  124.     return (NORMAL);
  125. }
  126.  
  127. /*************************************************************************
  128. *    ログイン処理
  129. *************************************************************************/
  130.  
  131. int        _CENTER01_login( char *ntm, char *center )
  132. {
  133.     int        i, ret, retry;
  134.     char    *name, *tel, *id, *pw, *para;
  135.     int        argc;
  136.     char    *s, **argv;
  137.     long    tm;
  138.     char    *cns;
  139.     char    *mos;
  140.  
  141.     mos = NULL;
  142.     cns = NtmGetCnsPtr(ntm);
  143. #ifdef    _TAROPYON_SYSTEM
  144.     /* ログ保存行数を増やす    */
  145.     if ( CnsGet_maxLinBuf(cns) < 99999 )
  146.         CnsSet_maxLinBuf(cns,99999);
  147. #endif
  148.     _center01_recKey = NtmCenterGetRecKey(center);
  149.  
  150.     name = NtmCenterGetName    ( center );
  151.     tel  = NtmCenterGetTel     ( center );
  152.     id   = NtmCenterGetID      ( center );
  153.     pw   = NtmCenterGetPassword( center );
  154.     if ( tel[0] == 0 || id[0] == 0 || pw[0] == 0 )
  155.     {
  156.         _ntm_errmsg_no_setup_id_and_pw();
  157.         if ( _CENTER01_para( ntm, center ) )
  158.             return (ERR);
  159.         id  = NtmCenterGetID      ( center );
  160.         pw  = NtmCenterGetPassword( center );
  161.         tel = NtmCenterGetTel     ( center );
  162.     }
  163.  
  164.     _ntm_dspmsg_dial_start( name, tel, cns );
  165.  
  166.     AplRecWrite("%s:Dial start tel.%s", RECKEY, tel );
  167.     if ( ntm_dialStart( ntm, tel ) != NORMAL )
  168.     {
  169. ABORT:    _CENTER01_abort( ntm, center );
  170.         if ( mos )    MOS_pop(mos);
  171.         return (ERR);
  172.     }
  173.  
  174.     mos = MOS_push();
  175.     MOS_curType(MOSCUR_TIME);
  176.     MOS_CON();
  177.     AplRecWrite("%s:Connect", RECKEY );
  178.  
  179.     NTM_wait(1);
  180.     ret = NTM_waitStr( ntm, 30, "IDを入力してください :", NULL );
  181.     if ( ret == NTM_WAIT_CANCEL )
  182.         goto    ABORT;
  183.     NTM_wait(1);
  184.     NTM_rsPuts( ntm, id );    NTM_rsPuts(ntm,"\r");
  185.  
  186.     ret = NTM_waitStr( ntm, 30, "パスワードを入力してください :", NULL);
  187.     if ( ret == NTM_WAIT_CANCEL )
  188.         goto    ABORT;
  189.     NTM_wait(1);
  190.     NTM_rsPuts( ntm, pw );    NTM_rsPuts(ntm,"\r");
  191.  
  192.     /* ログイン時間    */
  193.     time(&tm);
  194.     NtmCenterSetTime( center, NTM_TIME_LOGIN, tm );
  195.     AplRecWrite("%s:Login successful", RECKEY );
  196.     NTM_rsPuts(ntm,"\r");
  197.     MOS_pop(mos);
  198.  
  199.     return (NORMAL);
  200. }
  201.  
  202.  
  203. /*************************************************************************
  204. *    ログアウト処理
  205. *************************************************************************/
  206.  
  207. int        _CENTER01_logout( char *ntm, char *center )
  208. {
  209.     int        ret;
  210.     long    tm;
  211.  
  212.     time(&tm);
  213.     NtmCenterSetTime( center, NTM_TIME_LOGOUT, tm );
  214.     AplRecWrite("%s:Logout", RECKEY);
  215.     NTM_wait(1);
  216.     NTM_rsPuts( ntm, "E\rY\r");
  217.     NTM_waitInstr( ntm, 30, "NO CARRIER", NULL );
  218.     NTM_offline(ntm, DTR_OFF_TIME);
  219.     AplRecWrite("%s:Disconnect", RECKEY);
  220.  
  221.     return (NORMAL);
  222. }
  223.  
  224. /*************************************************************************
  225. *    受信行のチェック
  226. *************************************************************************/
  227.  
  228. int        _CENTER01_lineCheck( char *ntm, char *buf )
  229. {
  230.     return (NORMAL);
  231. }
  232.  
  233. /*************************************************************************
  234. *    入力文字列の送信
  235. *************************************************************************/
  236.  
  237. int        _CENTER01_inputCheck( char *ntm, char *s )
  238. {
  239.     NTM_rsPuts( ntm, s    );
  240.     NTM_rsPuts( ntm, "\r" );
  241.     return (NORMAL);
  242. }
  243.  
  244. /*************************************************************************
  245. *    フィルタ設定メニュー
  246. *************************************************************************/
  247.  
  248. int        _CENTER01_filterMenu( char *ntm, int x, int y )
  249. {
  250.     return    NtmUsr_filterMenu( ntm, x, y );
  251. }
  252.  
  253. int        CCI_dspCenter01Stt()
  254. {
  255.     char    *center;
  256.     char    *name;
  257.     long    loginTime, logoutTime;
  258.     char    t1[32], t2[32];
  259.  
  260.     if ( (center = NTM_getCenter(CENTERKEY)) == NULL )
  261.         return (ERR);
  262.     name = NtmCenterGetName(center);
  263.     loginTime  = NtmCenterGetTime( center, NTM_TIME_LOGIN );
  264.     logoutTime = NtmCenterGetTime( center, NTM_TIME_LOGOUT );
  265.     DLG_tmpMsgBox( DLGPOS_CENTER_OF_SCN, DLGPOS_CENTER_OF_SCN, 
  266.         C_MBLACK, C_DLGBASE, COLMIX(C_INFO,C_GRAY),
  267.         "  センター名 : %s\n  Login time       %s  \n  Last logout time %s  ",
  268.         name, GetAsciiTime(t1, loginTime), GetAsciiTime(t2,logoutTime) );
  269.     return (NORMAL);
  270. }
  271.  
  272. #undef    CENTERKEY
  273. #undef    RECKEY
  274.